package com.lagou.rocket.controller;

import com.lagou.rocket.dto.OrderDTO;
import com.lagou.rocket.pojo.Order;
import com.lagou.rocket.service.OrderService;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;


    /**
     * 下订单
     *
     * @param orderDTO
     * @return
     */
    @PostMapping("/create")
    public String createOrder(@RequestBody OrderDTO orderDTO) {
        return orderService.createOrder(orderDTO);
    }

    /**
     * 查询订单
     *
     * @param orderId
     * @return
     */
    @GetMapping("/get/{orderId}")
    public Order get(@PathVariable Long orderId) {
        return orderService.getOrderById(orderId);
    }

    /**
     * 支付
     *
     * @param orderId
     * @return
     */
    @PostMapping("/pay/{orderId}")
    public String pay(@PathVariable Long orderId) {
        return orderService.pay(orderId);
    }
}
